package com.jijuxie.message.websocket;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import jakarta.websocket.Session;

public class OnlineManager {

    private static final Map<Long, Session> ONLINE_USERS = new ConcurrentHashMap<>();

    public static void add(Long userId, Session session) {
        ONLINE_USERS.put(userId, session);
    }

    public static void remove(Long userId) {
        ONLINE_USERS.remove(userId);
    }

    public static Session get(Long userId) {
        return ONLINE_USERS.get(userId);
    }

    public static boolean isOnline(Long userId) {
        return ONLINE_USERS.containsKey(userId);
    }
}
